<template>
  <a-card :bordered="false">
    <div class="page-body">
      <p>{{ l('LicenseInfo') }}:</p>
      <p>{{ l('SystemCode') }}: {{ abp.setting.get('SystemCode') }}</p>
      <p>{{ l('LicensedTo') }}: {{ licenseInfo.licensedTo }}</p>
      <p>{{ l('LicenseType') }}: {{ l(licenseTypeDisplayName) }}</p>
      <p>{{ l('Expires') }}: {{ expires }}</p>
      <p>{{ l('LicenseMaxUser') }}: {{ licenseInfo.maxUser }}</p>
      <p>{{ l('SupportCode') }}: {{ licenseInfo.id }}</p>

      <div>
        <set-license></set-license>
      </div>
    </div>
  </a-card>
</template>

<script lang="ts">
  import { defineComponent } from 'vue';
  import { enumService } from '/@/shared/utils/enum.service';
  import { AppComponentBase, ProjectLicense } from '../shared';
  import SetLicense from './set-license/set-license.vue';
  export default defineComponent({
    name: 'project-license',
    components: {
      SetLicense,
    },
    mixins: [AppComponentBase],
    data() {
      return {
        licenseInfo: new ProjectLicense(),
        licenseTypeDisplayName: '',
        systemCode: '',
        expires: '',
      };
    },
    created() {
      this.systemCode = abp.setting.get('SystemCode');
      this.licenseInfo = new ProjectLicense(JSON.parse(abp.setting.get('License')));
      var dateee = new Date(this.licenseInfo.expires.toString()).toJSON();
      this.expires = new Date(+new Date(dateee) + 8 * 3600 * 1000)
        .toISOString()
        .replace(/T/g, ' ')
        .replace(/\.[\d]{3}Z/, '');
      this.licenseTypeDisplayName = enumService
        .getData('ProjectLicenseType')
        .find((o) => o.value === this.licenseInfo.licenseTypeString).displayName;
    },
  });
</script>
